home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2002 #3 / Amiga Plus CD - 2002 - No. 03.iso / AmigaPlus / Tools / Development / renderlib40 / src / rnd_mapping.c < prev    next >
Encoding:
C/C++ Source or Header  |  2002-12-21  |  2.4 KB  |  118 lines

  1.  
  2. #include "lib_init.h"
  3. #include "lib_debug.h"
  4. #include <render/render.h>
  5. #include <proto/utility.h>
  6. #include <proto/exec.h>
  7. #include "rnd_palette.h"
  8.  
  9. /* 
  10. **    the implementation of mapping-engines is a dummy for now.
  11. */
  12.  
  13. LIBAPI RNDMAP *CreateMapEngineA(RNDPAL *palette, struct TagItem *tags)
  14. {
  15.     return (RNDMAP *) palette;
  16. }
  17.  
  18. LIBAPI void DeleteMapEngine(RNDMAP *mapengine)
  19. {
  20. }
  21.  
  22. LIBAPI ULONG MapRGBArrayA(RNDPAL *pal, ULONG *src, UWORD width, UWORD height, UBYTE *dst, struct TagItem *tags)
  23. {
  24.     ULONG result = CONV_NO_DATA;
  25.     if (pal && src && width && height && dst)
  26.     {
  27.         ObtainSemaphore(&pal->lock);
  28.         
  29.         result = CONV_NOT_ENOUGH_MEMORY;
  30.         if (GetP2Table(pal))
  31.         {
  32.             LONG tsw = GetTagData(RND_SourceWidth, width, tags);
  33.             LONG tdw = GetTagData(RND_DestWidth, width, tags);
  34.             UBYTE *pentab = (UBYTE *) GetTagData(RND_PenTable, NULL, tags);
  35.             LONG y, x;
  36.  
  37.             if (pentab)
  38.             {
  39.                 for (y = 0; y < height; ++y)
  40.                 {
  41.                     for (x = 0; x < width; ++x)
  42.                     {
  43.                         *dst++ = pentab[P2Lookup(pal, *src++)];
  44.                     }
  45.                     src += tsw - width;
  46.                     dst += tdw - width;
  47.                 }
  48.             }
  49.             else
  50.             {
  51.                 for (y = 0; y < height; ++y)
  52.                 {
  53.                     for (x = 0; x < width; ++x)
  54.                     {
  55.                         *dst++ = P2Lookup(pal, *src++);
  56.                     }
  57.                     src += tsw - width;
  58.                     dst += tdw - width;
  59.                 }
  60.             }
  61.             result = CONV_SUCCESS;
  62.         }
  63.  
  64.         ReleaseSemaphore(&pal->lock);
  65.     }
  66.     
  67.     return result;
  68. }
  69.  
  70. LIBAPI ULONG MapChunkyArrayA(RNDMAP *pal, UBYTE *src, RNDPAL *srcpal, UWORD width, UWORD height, UBYTE *dst, struct TagItem *tags)
  71. {
  72.     ULONG result = CONV_NO_DATA;
  73.     if (pal && src && srcpal && width && height && dst)
  74.     {    
  75.         ObtainSemaphore(&pal->lock);
  76.         ObtainSemaphoreShared(&srcpal->lock);
  77.         
  78.         result = CONV_NOT_ENOUGH_MEMORY;
  79.         if (GetP2Table(pal))
  80.         {
  81.             LONG tsw = GetTagData(RND_SourceWidth, width, tags);
  82.             LONG tdw = GetTagData(RND_DestWidth, width, tags);
  83.             UBYTE *pentab = (UBYTE *) GetTagData(RND_PenTable, NULL, tags);
  84.             LONG y, x;
  85.  
  86.             if (pentab)
  87.             {
  88.                 for (y = 0; y < height; ++y)
  89.                 {
  90.                     for (x = 0; x < width; ++x)
  91.                     {
  92.                         *dst++ = pentab[P2Lookup(pal, srcpal->table[*src++])];
  93.                     }
  94.                     src += tsw - width;
  95.                     dst += tdw - width;
  96.                 }
  97.             }
  98.             else
  99.             {
  100.                 for (y = 0; y < height; ++y)
  101.                 {
  102.                     for (x = 0; x < width; ++x)
  103.                     {
  104.                         *dst++ = P2Lookup(pal, srcpal->table[*src++]);
  105.                     }
  106.                     src += tsw - width;
  107.                     dst += tdw - width;
  108.                 }
  109.             }
  110.             result = CONV_SUCCESS;
  111.         }
  112.  
  113.         ReleaseSemaphore(&srcpal->lock);
  114.         ReleaseSemaphore(&pal->lock);
  115.     }
  116.     return result;
  117. }
  118.